<!DOCTYPE html>
<html data-ng-app=" ">
<head>
	<meta charset="UTF-8">
	<title>DGWeb</title>
	
	<script src="js/angular.min.js"></script>
	<link rel="stylesheet" href="css/bootstrap.min.css"> <!-- For Dropdown button -->
	<link rel="stylesheet" href="css/bootstrap-theme.min.css"> <!-- For Dropdown button -->
	<script src="js/jquery.min.js"></script> <!-- For Dropdown button -->
	<script src="js/bootstrap.min.js"></script> <!-- For Dropdown button -->
	<script src="js/mainWindow.js"></script>
	<link rel="stylesheet" href="css/MainStyle.css" />
</head>
<body>
	<div class="container-fluid " data-ng-controller="MainWindow" data-ng-init="checkSession('mainWindow')">
		<div class="jumbotron"><h1><br></h1></div>
		<div class="panel panel-default  panel-half-transparent"> <!-- Panel User profile and logout -->
		  <div class="panel-body">
		  	<ul  class="nav nav-pills">
		  		<li id="WelcomeLabel" >Welcome , {{Nick}}</li>
		  	 	<li id="LogoutButton">
		  	 		<form method="post" action = "logout">
		  	 			<button type="submit" class="btn btn-default" >Logout</button>
		  	 		</form>
		  	 	</li>
		  	 	<li id="UserProfileButton">
		  	 		<button class="btn btn-default" data-ng-click="btnShowMemberProfile(Nick)" >User Profile</button>

		  	 	</li>
	  	 	</ul>
	  	 	
		  </div>
		</div>  <!-- End Panel User profile and logout -->
		<div data-ng-init="btnDiscover(1)"> <!--Main Window -->
			<div class="panel panel-default" id="SendMessageDiv" > <!-- Send New Message -->
			  <div class="panel-heading">
			    <h3 class="panel-title">Create New Message</h3>
			  </div>
			  <div class="panel-body"><!-- Send Message -->
			  	<form data-ng-submit="messageinsert()">
					<textarea name="message_text" id="SendMessageText" rows="2" data-ng-model="message_text" required data-ng-maxlength="140"></textarea>
					 <br>
					 <br>
					 <small data-ng-model="err" id="SendMessageErrorSmallLebal">{{err}} </small>
					 <button type="submit" class="btn btn-default" id="SendMessageButton">Post </button>
				</form>
			  </div>
			</div> <!--End Send New Message -->
			<br>
			
			<div class="well well-sm LineSeperatorDiv panel-half-transparent" > <!-- Line Seperator -->
			<label class="DiscoverOptionText" data-ng-bind="DiscoverOptionText"></label>
				<div class="SetDiscoverToCenter">
					<div class="btn-group">
			            <button type="button" data-toggle="dropdown" class="btn btn-default dropdown-toggle  ">Discover <span class="caret"></span></button>
			            <ul class="dropdown-menu">
			                <li><a data-ng-click="btnDiscover(1)" >New Messages</a></li>
			                <li><a data-ng-click="btnDiscover(2)" >Messages Of Users Who I Follow </a></li>
			                <li><a data-ng-click="btnDiscover(6)" >My Messages </a></li>
			            </ul>
			        </div>
		        </div>
			</div> <!-- End of line sepretor -->
			
			<br>
	
			<div  ><!-- ShowMessages-->
				 <div data-ng-repeat="x in result" > 
			   		<div class="panel panel-default panel-q-transparent" id="ShowMessageDiv">
		  				<!-- Who wrote and when -->
		  				<small id="ShowWhoWroteAndWhenSmallLebal"> Posted By: <a data-ng-click="btnShowMemberProfile(x.Nickname)"  id="red_user" ><span  data-ng-bind="x.Nickname"></span></a> ( <span data-ng-bind="x.Time"></span> )</small> 
		  				<br>
				  		<!-- The message -->	
					   	<div class="panel-body">
							<label data-ng-model="theMessage" id="ShowMessageTextLaebl"><span data-ng-bind-html="TurnToHtml(x.Text)" data-compile-template></span></label>
					  		
					  	</div>
						<div  id="ShowReplyDiv"> <!--reply field for every message-->
						   	<form name="replyForm" data-ng-submit="btnReply(x,1)" >
						   	<small>Reply:</small><br>
							   	<textarea name="message_text" id="SendReplyText" rows="2" data-ng-model="x.message_text_reply" required data-ng-maxlength="140"></textarea>
							   	<button type="submit" class="btn btn-default btn-sm" id="SendReplyButton">Reply </button>
						   		<div class="error" data-ng-show="replyForm.message_text.$invalid">
		    						<small class="error" data-ng-show="replyForm.message_text.$error.maxlength"><font color="red"> Reply cannot be longer than 140 characters.</font></small>
						  		</div>
						   </form>
					   	</div>
					   	<br>
					   	<div class = "DivCommentFollow"> <!-- show follow/comments Buttons -->
							<div class="btn-group " role="group"  >
								<button type="submit"  class="btn btn-default btn-sm" data-ng-click="btnRepublish(x)">Republish</button>
								<button type="submit"  class="btn btn-default btn-sm" data-ng-click="btnComment(x)" >Comments ( {{x.Comments }} )</button>
								<button type="submit" class="btn btn-default btn-sm" data-ng-click="btnFollow(x)" data-ng-show="{{x.FollowDisabled}}">Follow</button>
								<button type="submit" class="btn btn-default btn-sm" data-ng-click="btnUnFollow(x)" data-ng-show="{{x.UnFollowDisabled}}">UnFollow</button>
							</div>
						</div> <!-- end Show Follow/Comments Buttons -->
				   </div><!-- End show Message -->
				    <!--  Show Comments -->
				    <div data-ng-show="x.showComments">
					   <div data-ng-repeat="t in x.theComments" >
							<div id="ShowComments" class="panel panel-default  panel-q-transparent" >
								<small id="ShowWhoWroteAndWhenSmallLebal"> Posted By: <a data-ng-click="btnShowMemberProfile(t.Nickname)" id="red_user"><span data-ng-bind="t.Nickname"></span> </a>( <span data-ng-bind="t.Time"></span>  )</small> 
								<button type="submit"  class="btn btn-default btn-sm SetRepublishButtonInComment" data-ng-click="btnRepublishComment(t)">Republish</button>
								<br>
								<label data-ng-model="theComment" id="ShowCommentTextLaebl"><span data-ng-bind-html="TurnToHtml(t.Text)" data-compile-template></span></label>
				  		  	</div>
			  		  	</div> <!-- End Show Comments -->
		  		  	</div>
				   <br>
			  </div>  <!-- end of div ng-repeat -->
			   
			</div> <!--  end of div show Messages -->
		</div> <!-- end of div main window -->
	</div> <!--  end of container and ng-init CheckSession function -->
</body>
</html>